/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Laporan1.java
 *
 * Created on Nov 10, 2011, 3:02:49 PM
 */
package Manager;

import java.awt.GridLayout;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;
import javax.swing.table.DefaultTableModel;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRTableModelDataSource;
import net.sf.jasperreports.view.JasperViewer;

public class Laporan extends javax.swing.JPanel {

    private Date sou;
    private Date dest;

    /** Creates new form Laporan1 */
    public Laporan() {
        initComponents();
        dest = new GregorianCalendar().getTime();
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, -7);
        sou = cal.getTime();
        sourceChooser.setDate(sou);
        destChooser.setDate(dest);

    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        LaporanBulananpanel = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tableLaporanBulan = new javax.swing.JTable();
        printButton = new javax.swing.JButton();
        keluar = new javax.swing.JButton();
        monthChooser = new com.toedter.calendar.JMonthChooser();
        yearChooser = new com.toedter.calendar.JYearChooser();
        jLabel14 = new javax.swing.JLabel();
        lihatButton = new javax.swing.JButton();
        LaporanMingguanpanel = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        printBulananButton = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        keluarButton = new javax.swing.JButton();
        sourceChooser = new com.toedter.calendar.JDateChooser();
        destChooser = new com.toedter.calendar.JDateChooser();
        lihatbutton = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        tableLaporanMinggu = new javax.swing.JTable();
        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        radioMingguan = new javax.swing.JRadioButton();
        radiobulanan = new javax.swing.JRadioButton();
        pilihButton = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();

        LaporanBulananpanel.setBackground(new java.awt.Color(255, 255, 255));
        LaporanBulananpanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "LAPORAN BULANAN", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 24), new java.awt.Color(0, 0, 102))); // NOI18N
        LaporanBulananpanel.setPreferredSize(new java.awt.Dimension(684, 394));

        tableLaporanBulan.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Kode Barang", "Nama Barang", "Stok", "Total", "Barang Terjual"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane3.setViewportView(tableLaporanBulan);

        printButton.setText("Print");
        printButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                printButtonActionPerformed(evt);
            }
        });

        keluar.setText("Keluar");
        keluar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keluarActionPerformed(evt);
            }
        });

        jLabel14.setText("PILIH BULAN DAN TAHUN");

        lihatButton.setText("lihat");
        lihatButton.setOpaque(false);
        lihatButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lihatButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout LaporanBulananpanelLayout = new javax.swing.GroupLayout(LaporanBulananpanel);
        LaporanBulananpanel.setLayout(LaporanBulananpanelLayout);
        LaporanBulananpanelLayout.setHorizontalGroup(
            LaporanBulananpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(LaporanBulananpanelLayout.createSequentialGroup()
                .addGroup(LaporanBulananpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(LaporanBulananpanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(monthChooser, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(yearChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(lihatButton))
                    .addGroup(LaporanBulananpanelLayout.createSequentialGroup()
                        .addGap(231, 231, 231)
                        .addComponent(printButton)
                        .addGap(57, 57, 57)
                        .addComponent(keluar))
                    .addGroup(LaporanBulananpanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(LaporanBulananpanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 652, Short.MAX_VALUE)))
                .addContainerGap())
        );
        LaporanBulananpanelLayout.setVerticalGroup(
            LaporanBulananpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(LaporanBulananpanelLayout.createSequentialGroup()
                .addGroup(LaporanBulananpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(LaporanBulananpanelLayout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(LaporanBulananpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(yearChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(monthChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(lihatButton))
                .addGap(44, 44, 44)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addGroup(LaporanBulananpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(printButton)
                    .addComponent(keluar))
                .addContainerGap(89, Short.MAX_VALUE))
        );

        LaporanMingguanpanel.setBackground(new java.awt.Color(255, 255, 255));
        LaporanMingguanpanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "LAPORAN MINGGUAN", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Comic Sans MS", 1, 18), new java.awt.Color(0, 0, 102))); // NOI18N

        jLabel10.setText("Tanggal Periode");

        printBulananButton.setText("Print");
        printBulananButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                printBulananButtonActionPerformed(evt);
            }
        });

        jLabel12.setText("SD");

        keluarButton.setText("Keluar");
        keluarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keluarButtonActionPerformed(evt);
            }
        });

        sourceChooser.setDateFormatString("dd-MM-yyyy");
        sourceChooser.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                sourceChooserPropertyChange(evt);
            }
        });

        destChooser.setDate(new GregorianCalendar().getTime());
        destChooser.setDateFormatString("dd-MM- yyyy");
        destChooser.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                destChooserPropertyChange(evt);
            }
        });

        lihatbutton.setText("Lihat");
        lihatbutton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lihatbuttonActionPerformed(evt);
            }
        });

        tableLaporanMinggu.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Kode Barang", "Nama Barang", "Stok", "Total", "Barang Terjual"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane4.setViewportView(tableLaporanMinggu);

        javax.swing.GroupLayout LaporanMingguanpanelLayout = new javax.swing.GroupLayout(LaporanMingguanpanel);
        LaporanMingguanpanel.setLayout(LaporanMingguanpanelLayout);
        LaporanMingguanpanelLayout.setHorizontalGroup(
            LaporanMingguanpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(LaporanMingguanpanelLayout.createSequentialGroup()
                .addGroup(LaporanMingguanpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(LaporanMingguanpanelLayout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sourceChooser, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(destChooser, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(lihatbutton))
                    .addGroup(LaporanMingguanpanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 652, Short.MAX_VALUE))
                    .addGroup(LaporanMingguanpanelLayout.createSequentialGroup()
                        .addGap(231, 231, 231)
                        .addComponent(printBulananButton)
                        .addGap(74, 74, 74)
                        .addComponent(keluarButton)))
                .addContainerGap())
        );
        LaporanMingguanpanelLayout.setVerticalGroup(
            LaporanMingguanpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(LaporanMingguanpanelLayout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(LaporanMingguanpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(LaporanMingguanpanelLayout.createSequentialGroup()
                        .addComponent(lihatbutton)
                        .addGap(35, 35, 35))
                    .addGroup(LaporanMingguanpanelLayout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addGap(44, 44, 44))
                    .addGroup(LaporanMingguanpanelLayout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addGap(44, 44, 44))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, LaporanMingguanpanelLayout.createSequentialGroup()
                        .addGroup(LaporanMingguanpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(destChooser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(sourceChooser, javax.swing.GroupLayout.DEFAULT_SIZE, 20, Short.MAX_VALUE))
                        .addGap(38, 38, 38)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(LaporanMingguanpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(printBulananButton)
                    .addComponent(keluarButton))
                .addGap(76, 76, 76))
        );

        setBackground(new java.awt.Color(204, 255, 204));
        setPreferredSize(new java.awt.Dimension(684, 370));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "PILIH JENIS LAPORAN", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.ABOVE_TOP, new java.awt.Font("Comic Sans MS", 1, 18), new java.awt.Color(0, 0, 102))); // NOI18N

        radioMingguan.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(radioMingguan);
        radioMingguan.setFont(new java.awt.Font("Comic Sans MS", 1, 14)); // NOI18N
        radioMingguan.setText("Laporan Mingguan");

        radiobulanan.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(radiobulanan);
        radiobulanan.setFont(new java.awt.Font("Comic Sans MS", 1, 14));
        radiobulanan.setText("Laporan Bulanan");

        pilihButton.setText("Pilih");
        pilihButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pilihButtonActionPerformed(evt);
            }
        });

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gambar/leaf_banner_gray.png"))); // NOI18N
        jLabel2.setText("jLabel2");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 672, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(241, 241, 241)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(radioMingguan)
                    .addComponent(radiobulanan))
                .addContainerGap(288, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(282, 282, 282)
                .addComponent(pilihButton)
                .addContainerGap(339, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(62, 62, 62)
                .addComponent(radiobulanan)
                .addGap(18, 18, 18)
                .addComponent(radioMingguan)
                .addGap(28, 28, 28)
                .addComponent(pilihButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 76, Short.MAX_VALUE)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printButtonActionPerformed
        try {
            int x = monthChooser.getMonth() + 1;
            int y = yearChooser.getYear();
            DefaultTableModel ds = (DefaultTableModel) tableLaporanBulan.getModel();
            JRTableModelDataSource datas = new JRTableModelDataSource(ds);
            String reportSource = "./laporan/laporBulanan.jrxml";

            JasperReport jr = JasperCompileManager.compileReport(reportSource);

            Map<String, Object> params = new HashMap<String, Object>();
            params.put("bln", x);
            params.put("thn", y);
            JasperPrint jp = JasperFillManager.fillReport(jr, params, datas);

            JasperViewer.viewReport(jp, false);
        } catch (JRException ex) {
            Logger.getLogger(Laporan.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_printButtonActionPerformed

    private void keluarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keluarButtonActionPerformed
        this.removeAll();
        this.setLayout(new GridLayout(1, 1));
        this.add(jPanel1);
        this.setVisible(false);
        this.setVisible(true);
    }//GEN-LAST:event_keluarButtonActionPerformed

    private void keluarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keluarActionPerformed
        this.removeAll();
        this.setLayout(new GridLayout(1, 1));
        this.add(jPanel1);
        this.setVisible(false);
        this.setVisible(true);
    }//GEN-LAST:event_keluarActionPerformed

    private void lihatButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lihatButtonActionPerformed
        try {
            isiTabelBulanan();
        } catch (SQLException ex) {
            Logger.getLogger(Laporan.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_lihatButtonActionPerformed

    private void lihatbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lihatbuttonActionPerformed
        try {
            isiTabelMingguan();
        } catch (SQLException ex) {
            Logger.getLogger(Laporan.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_lihatbuttonActionPerformed

    private void pilihButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pilihButtonActionPerformed
        if (radiobulanan.isSelected() == true) {
            this.removeAll();
            this.setLayout(new GridLayout(1, 1));
            this.add(LaporanBulananpanel);
            this.setVisible(false);
            this.setVisible(true);
        } else if (radioMingguan.isSelected() == true) {
            this.removeAll();
            this.setLayout(new GridLayout(1, 1));
            this.add(LaporanMingguanpanel);
            this.setVisible(false);
            this.setVisible(true);
        }
    }//GEN-LAST:event_pilihButtonActionPerformed

private void sourceChooserPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_sourceChooserPropertyChange
    Date sou = sourceChooser.getDate();
    if (this.sou.getDate() != sou.getDate()
            || this.sou.getMonth() != sou.getMonth()
            || this.sou.getYear() != sou.getYear()) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(sou);
        cal.add(Calendar.DATE, 7);
        this.sou = sou;
        this.dest = cal.getTime();
        destChooser.setDate(cal.getTime());
    }
}//GEN-LAST:event_sourceChooserPropertyChange

private void destChooserPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_destChooserPropertyChange
    Date dest = destChooser.getDate();
    if (this.dest.getDate() != dest.getDate()
            || this.dest.getMonth() != dest.getMonth()
            || this.dest.getYear() != dest.getYear()) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(dest);
        cal.add(Calendar.DATE, -7);
        this.dest = dest;
        this.sou = cal.getTime();
        sourceChooser.setDate(cal.getTime());
    }
}//GEN-LAST:event_destChooserPropertyChange

private void printBulananButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printBulananButtonActionPerformed
     try {
        java.util.Date date = this.sourceChooser.getDate();
        java.util.Date dateb = this.destChooser.getDate();
        DefaultTableModel ds = (DefaultTableModel) tableLaporanMinggu.getModel();
        JRTableModelDataSource datas = new JRTableModelDataSource(ds);
        String reportSource = "./laporan/laporMingguan.jrxml";

        JasperReport jr = JasperCompileManager.compileReport(reportSource);

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("tglawal", date);
        params.put("tglakhir", dateb);
        JasperPrint jp = JasperFillManager.fillReport(jr, params, datas);

        JasperViewer.viewReport(jp, false);
    } catch (JRException ex) {
        Logger.getLogger(Laporan.class.getName()).log(Level.SEVERE, null, ex);
    }
}//GEN-LAST:event_printBulananButtonActionPerformed

    public void isiTabelBulanan() throws SQLException {
        int x = monthChooser.getMonth() + 1;
        int y = yearChooser.getYear();
        LaporanController lc = new LaporanController();
        Object isitabel[][] = lc.getAllBarangBulan(x, y);
        String judulkolom[] = {"Kode Barang", "Nama Barang", "Stok", "Total", "Barang Terjual"};
        tableLaporanBulan.setModel(new DefaultTableModel(isitabel, judulkolom));
    }

    public void isiTabelMingguan() throws SQLException {
        int x = monthChooser.getMonth() + 1;
        int y = yearChooser.getYear();
        LaporanController lc = new LaporanController();
        Object isitabel[][] = lc.getAllBarangMinggu(sourceChooser.getDate(), destChooser.getDate());
        String judulkolom[] = {"Kode Barang", "Nama Barang", "Stok", "Total", "Barang Terjual"};
        tableLaporanMinggu.setModel(new DefaultTableModel(isitabel, judulkolom));
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel LaporanBulananpanel;
    private javax.swing.JPanel LaporanMingguanpanel;
    private javax.swing.ButtonGroup buttonGroup1;
    private com.toedter.calendar.JDateChooser destChooser;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JButton keluar;
    private javax.swing.JButton keluarButton;
    private javax.swing.JButton lihatButton;
    private javax.swing.JButton lihatbutton;
    private com.toedter.calendar.JMonthChooser monthChooser;
    private javax.swing.JButton pilihButton;
    private javax.swing.JButton printBulananButton;
    private javax.swing.JButton printButton;
    private javax.swing.JRadioButton radioMingguan;
    private javax.swing.JRadioButton radiobulanan;
    private com.toedter.calendar.JDateChooser sourceChooser;
    private javax.swing.JTable tableLaporanBulan;
    private javax.swing.JTable tableLaporanMinggu;
    private com.toedter.calendar.JYearChooser yearChooser;
    // End of variables declaration//GEN-END:variables
}
